layui.define(['Mock', 'apiCommon', 'qs', 'store'], function (exports) {
	var Mock = layui.Mock,
		commonApi = layui.apiCommon,
		qs = layui.qs,
        store = layui.store;

	function commonMock() {
		Mock.setup({
			timeout: '50-500'
		})

		/**
		 * @author: ares
		 * @date: 2020/1/29 13:25
		 * @description: 获取主菜单
		 */
		Mock.mock(RegExp(commonApi.getMainMenu + '[^\.]*$'), {
			code: 2000,
			msg: '获取主菜单成功',
			data: [
				{
					id: 1,
					icon: 'fa-asterisk',
					name: '内容管理'
				},
				{
					id: 2,
					icon: 'fa-file',
					name: '文件管理'
				}
			]
		})

		/**
		 * @author: ares
		 * @date: 2020/1/29 13:25
		 * @description: 获取侧边菜单
		 */
		Mock.mock(RegExp(commonApi.getSideMenu + '[^\.]*$'), function (options) {
			var params = qs.parse(options.url.split('?')[1]),
				mainMenuId = params.id,
				roleId = store.session.get('roleId'),
                profile = store.get('profile'),
				isYueYangHospital = profile && profile.institution && profile.institution.hospital && profile.institution.hospital.name == '上海市中医药大学附属岳阳医院',
				menu = {
					yueyangHospitalBaseMenus: [
						{
							"title": "首页",
							"icon": "fa-home",
							"href": "/homepage",
							"spread": false
						},
						{
							"title": "转诊病例",
							"icon": "fa-retweet",
							"href": "/referral/list",
							"spread": false
						},
                        {
                            "title": "会诊病例",
                            "icon": "fa-users",
                            "href": "/consultation/list",
                            "spread": false
                        },
						{
							"title": "整体评估",
							"icon": "fa-edit",
							"href": "/evaluation/list",
							"spread": false
						},
						{
							"title": "训练处方",
							"icon": "fa-child",
							"href": "/training/list",
							"spread": false
						},
						{
							"title": "治疗师排班",
							"icon": "fa-calendar",
							"href": "/schedule/mgr",
							"spread": false
						},
						{
							"title": "消息管理",
							"icon": "fa-commenting",
							"href": "",
							"spread": false,
							"children": [
								{
									"title": "我的消息",
									"icon": "fa-comments",
									"href": "/message/self",
									"spread": false
								},
								{
									"title": "历史任务",
									"icon": "fa-comment-o",
									"href": "/message/overTask",
									"spread": false
								},
								{
									"title": "待办任务",
									"icon": "fa-comment",
									"href": "/message/task",
									"spread": false
								},
							]
						},
					],
                    yueyangHospitalDirectorMenus: {
                        "title": "系统管理",
                        "icon": "fa-cogs",
                        "href": "",
                        "spread": false,
                        "children": [
                            {
                                "title": "质控统计",
                                "icon": "fa-line-chart",
                                "href": "/setting/ctrl",
                                "spread": false
                            },
                            {
                                "title": "人员管理",
                                "icon": "fa-users",
                                "href": "/setting/person",
                                "spread": false
                            },
                            {
                                "title": "实习老师管理",
                                "icon": "fa-user-o",
                                "href": "/setting/internship",
                                "spread": false
                            },
                            {
                                "title": "项目管理",
                                "icon": "fa-credit-card",
                                "href": "/setting/project",
                                "spread": false
                            },
                            {
                                "title": "套餐管理",
                                "icon": "fa-cubes",
                                "href": "/setting/combo",
                                "spread": false
                            }
                        ]
                    },
					otherHospitalMenus: [
                        {
                            "title": "首页",
                            "icon": "fa-home",
                            "href": "/homepage",
                            "spread": false
                        },
                        {
                            "title": "转诊病例",
                            "icon": "fa-retweet",
                            "href": "/referral/list",
                            "spread": false
                        },
                        {
                            "title": "我的消息",
                            "icon": "fa-comments",
                            "href": "/message/self",
                            "spread": false
                        },
					],
                    otherHospitalDirectorMenus: [
                        {
                            "title": "人员管理",
                            "icon": "fa-users",
                            "href": "/setting/person",
                            "spread": false
                        },
                    ]
				},
				usedMenu = [];
			if(isYueYangHospital){
                if(roleId == 2){
                    usedMenu = [].concat(menu.yueyangHospitalBaseMenus,[menu.yueyangHospitalDirectorMenus])
                }else {
                    usedMenu = [].concat(menu.yueyangHospitalBaseMenus)
                }
			}else {
                if(roleId == 2){
                    usedMenu = [].concat(menu.otherHospitalMenus,menu.otherHospitalDirectorMenus)
                }else {
                    usedMenu = [].concat(menu.otherHospitalMenus)
                }
			}

			return {
				code: 2000,
				msg: '获取侧边菜单成功',
				data: mainMenuId ? menu[mainMenuId] : usedMenu
			}
		})
	}

	exports("commonMock", commonMock);
})